package com.software.graduationproject.commons.select;

import com.baomidou.mybatisplus.core.metadata.Page;
import lombok.Data;

import java.util.*;

@Data
public class Select extends Pageable implements Page {

    private Map<String, Object> params;

    public Select() {
        this.params = new HashMap();
        this.no = 1L;
        this.size = 20L;
        this.data = new ArrayList();
        this.orders = new ArrayList();
        this.isSearchPage = true;
    }
    public Select(Map<String, Object> params) {
        this.params = new HashMap();
        this.no = 1L;
        this.size = 20L;
        this.data = new ArrayList();
        this.orders = new ArrayList();
        this.isSearchPage = true;
        if (params != null && !params.isEmpty()) {
            params.forEach((k, v) -> {
                this.addParam(k, v);
            });
        }

    }
    public Select addParam(String key, Object value) {
        this.params.put(key, value);
        return this;
    }

    public <T> T getParam(String key) {
        return (T) this.params.get(key);
    }
}
